package com.admin.contorl;

import java.io.IOException;
import java.net.URL;

import com.admin.common.Show;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.scene.control.Menu;

public class adminViewControl {
    @FXML
    private Button btn_exit;
    @FXML
    private Menu menu1;
    @FXML
    private Menu menu2;

    @FXML
    private StackPane stackPane;
    @FXML
    private ImageView imageView;
    @FXML
    private Label usernameLabel;
    private String userName;

    public adminViewControl() {
    }

    public adminViewControl(String userName) {
        this.userName = userName;
    }

    @FXML
    public void initialize() {
        usernameLabel.setText(userName);
        menu1.getItems().forEach(item -> {
            item.setStyle("-fx-font-size: 16px;");
        });
        menu2.getItems().forEach(item -> {
            item.setStyle("-fx-font-size: 16px;");
        });
        menu1.setStyle("-fx-font-size: 16px;");
        menu2.setStyle("-fx-font-size: 16px;");
    }

    public void queryProvince() {
        try {
            Show.viewShow(stackPane, getClass().getResource("/com/admin/view/provinceView.fxml"));
            System.out.println("查询成功");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void queryFeedback() {
        try {
            URL url = getClass().getResource("/com/admin/view/feedbackView.fxml");
            Show.viewShow(stackPane, url);
            System.out.println("反馈查询成功");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void queryAQIconfirm() {
        try {
            Show.viewShow(stackPane, getClass().getResource("/com/admin/view/AQIconfirmView.fxml"));
            System.out.println("AQI确认查询成功");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void queryOther() {
        try {
            Show.viewShow(stackPane, getClass().getResource("/com/admin/view/otherView.fxml"));
            System.out.println("其他查询成功");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void exit() {
        try {
            Stage stage = (Stage) btn_exit.getScene().getWindow();
            URL url = getClass().getResource("/com/admin/view/IndexView.fxml");
            Show.show(stage, url, "登录页面");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void querydistributetotalstatis() {
        try {
            Show.viewShow(stackPane, getClass().getResource("/com/admin/view/AQIdistributetotalstatis.fxml"));
            System.out.println("其他查询成功");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }//aqitrendtotalstatis

    public void querytrendtotalstatis() {
        try {
            Show.viewShow(stackPane, getClass().getResource("/com/admin/view/AQItrendtotalstatis.fxml"));
            System.out.println("其他查询成功");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
